#!/usr/bin/env python
#-*- coding:utf8 -*-
import web
from app.models.model import Model
class Traffic(Model):
    table = 'traffics'

    #创建流量统计表
    def create(self,data):
        try:
            return self.insert(
                sid         = data['sid'],
                nid         = data['nid'],
                hit_byte    = int(data['hit_byte']/1024),
                hit_count   = data['hit_count'],
                total_byte  = int(data['total_byte']/1024),
                total_count = data['total_count'],
                status      = 2
            )
        except:
            return False

    #更新流量状态
    def update_by_status(self,_map):
        return self.save(_map, status = 1)
